{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    }
   ],
   "source": [
    "# Cell 1: Basic inline and line comments\n",
    "x = 1  # This is an inline comment\n",
    "print(x)  # Another inline comment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n"
     ]
    }
   ],
   "source": [
    "# Cell 2: Comments with duplicate definitions\n",
    "# This variable will be redefined later\n",
    "y = 10  # First definition\n",
    "print(y)  # Should preserve this comment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "40\n"
     ]
    }
   ],
   "source": [
    "# Cell 3: Redefinition with more comments\n",
    "# This is the second definition of y\n",
    "y = 20  # Second definition with inline comment\n",
    "result = y * 2  # Calculate result\n",
    "print(result)  # Print the result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 4 μs, sys: 1 μs, total: 5 μs\n",
      "Wall time: 8.11 μs\n",
      "cell_metadata.ipynb\n",
      "comments_preservation.ipynb\n",
      "duplicate_definitions_and_aug_assign.ipynb\n",
      "duplicate_definitions_read_before_write.ipynb\n",
      "duplicate_definitions_syntax_error.ipynb\n",
      "hides_markdown_cells.ipynb\n",
      "multiple_definitions_multiline.ipynb\n",
      "multiple_definitions.ipynb\n",
      "pip_commands.ipynb\n"
     ]
    }
   ],
   "source": [
    "# Cell 4: Magic commands with comments\n",
    "%time x = 5  # Time this operation\n",
    "# Comment before magic\n",
    "%ls  # List files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "UsageError: Cell magic `%%sql` not found.\n"
     ]
    }
   ],
   "source": [
    "%%sql\n",
    "-- SQL comment inside magic\n",
    "SELECT * FROM table  -- Another SQL comment\n",
    "WHERE id > 0  # Python-style comment in SQL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'numpy'",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mModuleNotFoundError\u001b[39m                       Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[7]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m      1\u001b[39m \u001b[38;5;66;03m# Cell 6: Comments with import statements\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mnumpy\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mnp\u001b[39;00m  \u001b[38;5;66;03m# Import numpy\u001b[39;00m\n\u001b[32m      3\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpandas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpd\u001b[39;00m  \u001b[38;5;66;03m# Import pandas\u001b[39;00m\n\u001b[32m      4\u001b[39m \u001b[38;5;66;03m# These imports might be duplicated elsewhere\u001b[39;00m\n",
      "\u001b[31mModuleNotFoundError\u001b[39m: No module named 'numpy'"
     ]
    }
   ],
   "source": [
    "# Cell 6: Comments with import statements\n",
    "import numpy as np  # Import numpy\n",
    "import pandas as pd  # Import pandas\n",
    "# These imports might be duplicated elsewhere"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'numpy'",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mModuleNotFoundError\u001b[39m                       Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[8]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m      1\u001b[39m \u001b[38;5;66;03m# Cell 7: Duplicate import with different comment\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mnumpy\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mnp\u001b[39;00m  \u001b[38;5;66;03m# Import numpy again with different comment\u001b[39;00m\n\u001b[32m      3\u001b[39m \u001b[38;5;66;03m# This should be deduplicated but preserve one of the comments\u001b[39;00m\n\u001b[32m      4\u001b[39m arr = np.array([\u001b[32m1\u001b[39m, \u001b[32m2\u001b[39m, \u001b[32m3\u001b[39m])  \u001b[38;5;66;03m# Create array\u001b[39;00m\n",
      "\u001b[31mModuleNotFoundError\u001b[39m: No module named 'numpy'"
     ]
    }
   ],
   "source": [
    "# Cell 7: Duplicate import with different comment\n",
    "import numpy as np  # Import numpy again with different comment\n",
    "# This should be deduplicated but preserve one of the comments\n",
    "arr = np.array([1, 2, 3])  # Create array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Cell 8: Complex expressions with comments\n",
    "# Calculate something complex\n",
    "z = (x * 2  # Multiply x by 2\n",
    "     + y)   # Add y to the result\n",
    "# Final comment in cell"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Cell 9: Augmented assignment with comments\n",
    "counter = 0  # Initialize counter\n",
    "counter += 1  # Increment counter (this will be transformed)\n",
    "# This should preserve comments during aug assign transformation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Cell 10: Function definitions with comments\n",
    "def my_function():  # Define a function\n",
    "    \"\"\"This is a docstring, not a comment.\"\"\"\n",
    "    # This is a comment inside the function\n",
    "    return 42  # Return a value\n",
    "# Comment after function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
